var commonjs = require ('@rollup/plugin-commonjs');
var configs = require ('./rollupConfig/index');
var adConfigs = require ('./rollupConfig/ad');
var defaultConfig = {
  format: 'iife',
  strict: false,
};

var commonConfig = {
  watch: {
    include: 'src/**',
  },
  plugins: [commonjs ()],
  external: ['config'],
};
var outputBaseDir = './src';
var baseDir = './src';

var rollupConfigs = [];
configs.forEach (config => {
  config.files.forEach (file => {
    rollupConfigs.push ({
      input: `${baseDir}${config.dir}/${file}.js`,
      output: {
        file: `${outputBaseDir}${config.dir}/${file}B.js`,
        name: `${file}`,
        extend: true,
        ...defaultConfig,
      },
      ...commonConfig,
    });
  });
});
var adRollupConfigs = [];
adConfigs.forEach (config => {
  config.files.forEach (file => {
    adRollupConfigs.push ({
      input: `${baseDir}${config.dir}/${file}.js`,
      output: {
        file: `${outputBaseDir}/${config.dir}/${file}B.js`,
        name: `${file}`,
        ...defaultConfig,
      },
      ...commonConfig,
    });
  });
});
module.exports = [...rollupConfigs, ...adRollupConfigs];
